#ifndef __ALLOCOBJECT_H
#define __ALLOCOBJECT_H
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

extern "C"
{
	void* OSMalloc(unsigned int size);
	void OSFree(void*p);
	void* OSCalloc(unsigned int count, unsigned int size);
	void*	OSRealloc(void *p, unsigned int oldsize, unsigned int newsize);
	int UTF8to16 (const char *pSrc, size_t sourceLength, wchar_t *target, size_t* targetLength);
}

class AllocObject
{
	//only define useful interface, maybe we should add more later when needed
public:
	static void* operator new(size_t size)
	{
		return malloc(size);
	}
	static void operator delete (void* p)
	{
		if(p)free(p);
	}

	static void* operator new[](size_t size)
	{
		return malloc(size);
	}

	static void operator delete[](void *p)
	{
		free(p);
	}
};

class GlueObject : public AllocObject
{
public:
	GlueObject(void);
	~GlueObject();
	static void*OSMalloc(unsigned int x);
	static void* OSCalloc(unsigned int count, unsigned int size);
	static void OSFree(void*p);
	static void*	OSRealloc(void *p, unsigned int oldsize, unsigned int newsize);
};

#endif